package com.suge.home.module.screen.json;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.Context;
import com.alibaba.citrus.turbine.Navigator;
import com.suge.order.dao.UserBizOrderDAO;
import com.suge.order.dao.dataobject.UserBizOrderDO;

public class DelNoSendBuyer{ 

@Autowired
private HttpServletRequest request;
@Autowired
private UserBizOrderDAO userBizOrderDAO;
public void execute(Context context, Navigator nav) {
	String buyer = request.getParameter("buyer");
	String userId = request.getParameter("userId");
	if(userId==null || userId==""){
		context.put("isSuccess", false);
		return;
	}
	long userIdNum =  Long.parseLong(userId);
	UserBizOrderDO userBizorderDO = userBizOrderDAO.getUserBizOrderByUserId(userIdNum);
	if(userBizorderDO==null){
		
	}
	else{
		String noSend = userBizorderDO.getNoSendUsers();
		if(noSend==null || noSend==""){
			context.put("isSuccess", true);
			return;
		}
		else{
			StringBuffer sb = new StringBuffer();
			String[] buyers = noSend.split(";");
			for(String one:buyers){
				if(!one.equals(buyer)){
					sb.append(one);
					sb.append(";");
				}
			}
			userBizorderDO.setNoSendUsers(sb.toString());
			userBizOrderDAO.updateUserBizOrderInfo(userBizorderDO);
		}
	}
	context.put("isSuccess", true);
	return;
}

public void setRequest(HttpServletRequest request) {
	this.request = request;
}
public HttpServletRequest getRequest() {
	return request;
}

public void setUserBizOrderDAO(UserBizOrderDAO userBizOrderDAO) {
	this.userBizOrderDAO = userBizOrderDAO;
}

public UserBizOrderDAO getUserBizOrderDAO() {
	return userBizOrderDAO;
}

}
